package com.example.controller.wechat;

import cn.hutool.core.util.StrUtil;
import com.example.pojo.web.Result;
import com.example.service.wechat.OrderService;
import com.example.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName OrderController
 * @Description: com.example.controller.wechat
 * @Auther: xiwd
 * @Date: 2022/4/19 - 04 - 19 - 0:29
 * @version: 1.0
 */
@Controller
@RequestMapping(value = "/order")
public class OrderController {
    //properties
    @Autowired
    private OrderService orderService;

    //methods
    /**
     * 创建新的订单
     * @param code
     * @param markerId
     * @return
     */
    @ResponseBody
    @RequestMapping("/add/order")
    public Result addOrder(String code, Integer markerId){
        return orderService.addOrder(code, markerId);
    }

    /**
     * 根据code查询订单
     * @param code
     * @return
     */
    @ResponseBody
    @RequestMapping("/select/all")
    public Result selectOrderByOpenId(String code){
        return orderService.selectOrderByOpenId(code);
    }

    /**
     * 根据订单编号更新订单状态
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/update/one")
    public Result updateOrderStatusById(Integer id,Integer status){
        return orderService.updateOrderStatusById(id, status);
    }
}
